package com.hxd.dao;

import com.hxd.pojo.*;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface UserDao {
    //插入员工信息
    @Insert("insert into users(nickname,username,password,worktime,sex,mobile,email,phone,homephone," +
            "workphone,fax,MSN,birthday,httpaddress,address,content,logoncount)" +
            " values(#{nickname},#{username},#{password},#{worktime},#{sex},#{mobile},#{email}," +
            "#{phone},#{homephone},#{workphone},#{fax},#{MSN}" +
            ",#{birthday},#{httpaddress},#{address},#{content},#{logoncount})")
    int insertuser(Users users);

    //查询所有员工信息条数
    @Select("select count(*) from users")
    int selectAlluser();

    //按条件查询员工信息
    List<Users> selectOneuser(@Param("users") Users users, @Param("page") Page<Users> page);

    //根据id查询员工
    @Select("select * from users where ID=#{id}")
    Users selectOne(int id);

    //修改员工信息
    @Insert("update users set " +
            "nickname=#{nickname},username=#{username},password=#{password}," +
            "worktime=#{worktime},sex=#{sex},mobile=#{mobile}," +
            "email=#{email},phone=#{phone},homephone=#{homephone}," +
            "workphone=#{workphone},fax=#{fax},MSN=#{MSN}," +
            "httpaddress=#{httpaddress},address=#{address},content=#{content}," +
            "logoncount=#{logoncount}" +
            " where ID=#{ID}")
    int updateuser(Users users);

    //删除员工
    @Delete("delete from users where ID=#{id}")
    int deleteUser(int id);

    //全部信息分页查询
    @Select("select ID,password,nickname,logoncount,mobile,birthday,phone,workphone from users limit #{pageStartIndex},#{pageSiae}")
    List<Users> selectPage(Page<Users> page);

    //按照条件查询信息条数
    int selectOneusernum(@Param("users") Users users, @Param("page") Page<Users> page);

    //根据登录账号查询员工信息
    @Select("select * from users where username=#{username}")
    Users queryuser(String username);
}
